package com.qf.flash.mvp.presenter;

import com.qf.dblib.dao.impl.UserMgr;
import com.qf.flash.http.HttpManager;
import com.qf.flash.mvp.contract.InsertResponseContract;
import com.qf.flashlib.base.BasePresenter;
import com.qf.flashlib.base.BaseSubscriber;
import com.qf.flashlib.util.RxUtils;

/**
 * Des：提交评价
 *
 * @author love
 */
public class InsertResponsePresenter extends BasePresenter<InsertResponseContract.View> implements InsertResponseContract.Presenter {
    // 评论商家
    @Override
    public void submitShopDatas(String shopId, String content, Float starNum, String orderId) {
        String uid = UserMgr.getInstance().getLoginUser().getUid();
        addSubscription(HttpManager.getInstance().getGsonHttpApi()
                .INSERT_SHOP_RESPONSE(uid, shopId, content,starNum,orderId)
                .compose(RxUtils.handleResult())
                .compose(RxUtils.io_main())
                .subscribeWith(new BaseSubscriber<Object>(mRootView) {
                    @Override
                    public void onSuccess(Object o) {
                        mRootView.submitShopSuccess();
                    }
                })
        );
    }
    // 评论剧本
    @Override
    public void submitPlayDatas(String playId, String content, Float starNum, String orderId) {
        String uid = UserMgr.getInstance().getLoginUser().getUid();
        addSubscription(HttpManager.getInstance().getGsonHttpApi()
                .INSERT_PLAY_RESPONSE(uid, playId, content,starNum,orderId)
                .compose(RxUtils.handleResult())
                .compose(RxUtils.io_main())
                .subscribeWith(new BaseSubscriber<Object>(mRootView) {
                    @Override
                    public void onSuccess(Object o) {
                        mRootView.submitPlaySuccess();
                    }
                })
        );
    }
}
